home *** CD-ROM | disk | FTP | other *** search
- import javax.microedition.lcdui.Command;
- import javax.microedition.lcdui.CommandListener;
- import javax.microedition.lcdui.Display;
- import javax.microedition.lcdui.Displayable;
- import javax.microedition.lcdui.Form;
- import javax.microedition.lcdui.TextField;
- import javax.microedition.rms.RecordStore;
-
- public class SetupChess implements CommandListener, ChessDisplayable {
- private TextField chessurl = null;
- private ChessLogic chesslogic = null;
- private ChessDisplayable chessreturn = null;
- private Form form;
- private Command OKCommand;
- private Command backCommand;
-
- public SetupChess(ChessLogic var1, ChessDisplayable var2) {
- this.chesslogic = var1;
- this.chessreturn = var2;
- this.initialize();
- }
-
- public void commandAction(Command var1, Displayable var2) {
- if (var1 == this.OKCommand) {
- if (this.store()) {
- MessageForm var3 = new MessageForm("Succes", "New URL stored", this.chessreturn);
- var3.makeCurrent(CU.getDisplay());
- } else {
- MessageForm var4 = new MessageForm("Failure", "URL storage failed", this);
- var4.makeCurrent(CU.getDisplay());
- }
- } else {
- this.chessreturn.makeCurrent(CU.getDisplay());
- }
-
- }
-
- private void initialize() {
- this.form = new Form("Setup Chess Engine");
- Object var1 = null;
- this.OKCommand = new Command("Store", 4, 1);
- this.backCommand = new Command("Back", 2, 1);
- this.form.append("Provide: \n");
-
- try {
- Object var2 = null;
- RecordStore var5 = RecordStore.openRecordStore("Chess", false);
- var4 = new String(var5.getRecord(2));
- var5.closeRecordStore();
- } catch (Exception var3) {
- CU.shout("RS init: " + ((Throwable)var3).getMessage());
- var4 = "";
- }
-
- this.chessurl = new TextField("Chess engine URL", var4, 150, 4);
- this.form.append(this.chessurl);
- this.form.addCommand(this.OKCommand);
- this.form.addCommand(this.backCommand);
- this.form.setCommandListener(this);
- }
-
- public void makeCurrent(Display var1) {
- var1.setCurrent(this.form);
- this.form.setCommandListener(this);
- }
-
- private boolean store() {
- Object var1 = null;
- String var2 = this.chessurl.getString();
-
- try {
- RecordStore var5 = RecordStore.openRecordStore("Chess", false);
- var5.setRecord(2, var2.getBytes(), 0, var2.length());
- var5.closeRecordStore();
- return true;
- } catch (Exception var4) {
- CU.shout("Store exception: " + ((Throwable)var4).getMessage());
- return false;
- }
- }
- }
-